home *** CD-ROM | disk | FTP | other *** search
/ Aminet 39 / Aminet 39 (2000)(Schatztruhe)[!][Oct 2000].iso / Aminet / game / shoot / Orbit_src.lha / Orbit / source / prefs.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-04  |  6.2 KB  |  162 lines

  1. /*
  2.     Amiga port by Oliver Gantert
  3.  
  4.     27.04.2000 - fixed some compiler warnings
  5. */
  6. /*
  7.  
  8. ORBIT, a freeware space combat simulator
  9. Copyright (C) 1999  Steve Belczyk <steve1@genesis.nred.ma.us>
  10.  
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15.  
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. GNU General Public License for more details.
  20.  
  21. You should have received a copy of the GNU General Public License
  22. along with this program; if not, write to the Free Software
  23. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  24.  
  25. */
  26.  
  27. #include "orbit.h"
  28.  
  29. /*
  30.  *  Read and write the preferences file
  31.  */
  32.  
  33. void WritePrefs()
  34. {
  35.   FILE *fd;
  36.  
  37.   Log ("WritePrefs: Writing preferences file"); 
  38.   
  39.   /* Open it */
  40.   if (NULL == (fd = fopen ("prefs.txt", "wt")))
  41.   {
  42.     Log ("WritePrefs: Can't open prefs.txt");
  43.     return;
  44.   }
  45.   
  46.   /* Write stuff */
  47.   fprintf (fd, "mission %s\n", mission.fn);
  48.   fprintf (fd, "screenwidth %d\n", ScreenWidth);
  49.   fprintf (fd, "screenheight %d\n", ScreenHeight);
  50.   fprintf (fd, "fullscreen %d\n", fullscreen);
  51.   fprintf (fd, "gamemode %s\n", gamemode);
  52.   fprintf (fd, "name %s\n", player.name);
  53.   fprintf (fd, "model %s\n", player.model);
  54.   fprintf (fd, "vulnerable %d\n", vulnerable); 
  55.   fprintf (fd, "fov %lf\n", fov);
  56.   fprintf (fd, "joy_throttle %d\n", joy_throttle);
  57.   fprintf (fd, "deadzone %lf\n", deadzone);
  58.   fprintf (fd, "starfield %d\n", starfield);
  59.   fprintf (fd, "drawhud %d\n", drawhud);
  60.   fprintf (fd, "showfps %d\n", showfps);
  61.   fprintf (fd, "gravity %d\n", gravity); 
  62.   fprintf (fd, "draw_orbits %d\n", draw_orbits); 
  63.   fprintf (fd, "orbit %d\n", orbit); 
  64.   fprintf (fd, "compression %lf\n", compression);
  65.   fprintf (fd, "junk %d\n", junk);
  66.   fprintf (fd, "sound %d\n", sound);
  67.   fprintf (fd, "show_names %d\n", show_names);
  68.   fprintf (fd, "screen_shot_num %d\n", screen_shot_num);
  69.   fprintf (fd, "rings %d\n", rings);
  70.   fprintf (fd, "ring_sectors %d\n", ring_sectors);
  71.   fprintf (fd, "textures %d\n", textures);
  72.   fprintf (fd, "realdistances %d\n", realdistances);
  73.   fprintf (fd, "weapon %d\n", player.weapon);
  74.   fprintf (fd, "mouse_control %d\n", mouse_control);
  75.   fprintf (fd, "mouse_flipx %d\n", mouse.flipx);
  76.   fprintf (fd, "mouse_flipy %d\n", mouse.flipy);
  77.   fprintf (fd, "flightmodel %d\n", player.flightmodel); 
  78.   fprintf (fd, "fullstop %d\n", fullstop); 
  79.   fprintf (fd, "superwarp %d\n", superwarp); 
  80.   fprintf (fd, "port %d\n", server.port);
  81.   fprintf (fd, "posx %lf\n", player.pos[0]);
  82.   fprintf (fd, "posy %lf\n", player.pos[1]);
  83.   fprintf (fd, "posz %lf\n", player.pos[2]);
  84.   fprintf (fd, "slices0 %d\n", slices0);
  85.   fprintf (fd, "stacks0 %d\n", stacks0);
  86.   fprintf (fd, "slices1 %d\n", slices1);
  87.   fprintf (fd, "stacks1 %d\n", stacks1);
  88.   fprintf (fd, "slices2 %d\n", slices2);
  89.   fprintf (fd, "stacks2 %d\n", stacks2);
  90.  
  91.   /* Adios */
  92.   fclose (fd);
  93. }
  94.  
  95. void ReadPrefs()
  96. {
  97.   FILE *fd;
  98.   char c1[64], c2[64];
  99.  
  100.   /* Open it */
  101.   if (NULL == (fd = fopen ("prefs.txt", "rt"))) return;
  102.  
  103.   Log ("ReadPrefs: Reading preferences file");
  104.   
  105.   /* Read Stuff */
  106.   while (2 == fscanf (fd, "%s %s", c1, c2))
  107.   {
  108.     Log ("ReadPrefs: %s %s", c1, c2);
  109.  
  110.     if (!strcasecmp (c1, "vulnerable")) vulnerable = atoi(c2);
  111.     else if (!strcasecmp (c1, "joy_throttle")) joy_throttle = atoi(c2);
  112.     else if (!strcasecmp (c1, "deadzone")) deadzone = atof(c2);
  113.     else if (!strcasecmp (c1, "starfield")) starfield = atoi(c2);
  114.     else if (!strcasecmp (c1, "drawhud")) drawhud = atoi(c2);
  115.     else if (!strcasecmp (c1, "showfps")) showfps = atoi(c2);
  116.     else if (!strcasecmp (c1, "gravity")) gravity = atoi(c2);
  117.     else if (!strcasecmp (c1, "junk")) junk = atoi(c2);
  118.     else if (!strcasecmp (c1, "sound")) sound = atoi(c2);
  119.     else if (!strcasecmp (c1, "show_names")) show_names = atoi(c2);
  120.     else if (!strcasecmp (c1, "screen_shot_num")) screen_shot_num = atoi(c2);
  121.     else if (!strcasecmp (c1, "mission")) strcpy (mission.fn, c2);
  122.     else if (!strcasecmp (c1, "name")) strcpy (player.name, c2);
  123.     else if (!strcasecmp (c1, "model")) strcpy (player.model, c2);
  124.     else if (!strcasecmp (c1, "rings")) rings = atoi(c2);
  125.     else if (!strcasecmp (c1, "textures")) textures = atoi(c2);
  126.     else if (!strcasecmp (c1, "realdistances")) realdistances = atoi(c2);
  127.     else if (!strcasecmp (c1, "screenwidth")) ScreenWidth = atoi(c2);
  128.     else if (!strcasecmp (c1, "screenheight")) ScreenHeight = atoi(c2); 
  129.     else if (!strcasecmp (c1, "fov")) fov = atof(c2);
  130.     else if (!strcasecmp (c1, "weapon")) player.weapon = atoi(c2);
  131.     else if (!strcasecmp (c1, "fullscreen")) fullscreen = atoi(c2);
  132.     else if (!strcasecmp (c1, "gamemode")) strcpy (gamemode, c2);
  133.     else if (!strcasecmp (c1, "mouse_control")) mouse_control = atoi(c2);
  134.     else if (!strcasecmp (c1, "mouse_flipx")) mouse.flipx = atoi(c2);
  135.     else if (!strcasecmp (c1, "mouse_flipy")) mouse.flipy = atoi(c2);
  136.     else if (!strcasecmp (c1, "flightmodel")) player.flightmodel = atoi(c2);
  137.     else if (!strcasecmp (c1, "ring_sectors")) ring_sectors = atoi(c2); 
  138.     else if (!strcasecmp (c1, "fullstop")) fullstop = atoi(c2); 
  139.     else if (!strcasecmp (c1, "superwarp")) superwarp = atoi(c2); 
  140.     else if (!strcasecmp (c1, "port")) server.port = atoi(c2);
  141.     else if (!strcasecmp (c1, "posx")) player.pos[0] = atof(c2);
  142.     else if (!strcasecmp (c1, "posy")) player.pos[1] = atof(c2);
  143.     else if (!strcasecmp (c1, "posz")) player.pos[2] = atof(c2);
  144.     else if (!strcasecmp (c1, "slices0")) slices0 = atoi(c2);
  145.     else if (!strcasecmp (c1, "stacks0")) stacks0 = atoi(c2);
  146.     else if (!strcasecmp (c1, "slices1")) slices1 = atoi(c2);
  147.     else if (!strcasecmp (c1, "stacks1")) stacks1 = atoi(c2);
  148.     else if (!strcasecmp (c1, "slices2")) slices2 = atoi(c2);
  149.     else if (!strcasecmp (c1, "stacks2")) stacks2 = atoi(c2); 
  150.     else if (!strcasecmp (c1, "draw_orbits")) draw_orbits = atoi(c2); 
  151.     else if (!strcasecmp (c1, "orbit")) orbit = atoi(c2); 
  152.     else if (!strcasecmp (c1, "compression")) compression = atof(c2); 
  153.     else 
  154.     {
  155.       Log ("ReadPrefs: Unrecognized entry: %s %s", c1, c2); 
  156.     }
  157.   }
  158.  
  159.   /* Sayanora */
  160.   fclose (fd);
  161. }
  162.